package com.xju.ikun.service.serviceImpl;


import com.xju.ikun.bean.SongBean;
import com.xju.ikun.bean.*;
import com.xju.ikun.dao.MsrListDao;
import com.xju.ikun.dao.SongDao;
import com.xju.ikun.dao.SonglistDao;
import com.xju.ikun.service.SongService;
import com.xju.ikun.service.SonglistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SongServiceImpl implements SongService{
    @Autowired
    private SongDao songDao;
    @Autowired
    private SonglistDao songlistDao;
    @Autowired
    private MsrListDao msrListDao;


    @Override
    public SongBean findBySongid(int songid) {
        return songDao.findBySongid(songid);
    }

    @Override
    public List<SongBean> findByListid(int listid) {

        List<SonglistBean> songlistBeans = songlistDao.findByListid(listid);
        List<SongBean> songBeans = new ArrayList<SongBean>();
        for (SonglistBean m1 : songlistBeans) {
            int a = m1.getSonglist_songid();
            SongBean songBean = songDao.findBySongid(a);
            songBeans.add(songBean);
        }
        return songBeans;
    }

    @Override
    public List<SongBean> selectLikeOne(String sname) {
        return songDao.selectLikeOne(sname);
    }

    @Override
    public List<SongBean> findByAlbumid(int aid) {
        return songDao.findByAlbumid(aid);
    }

    @Override
    public List<SongBean> findByUserid(int user_id) {

        List<MsrListBean> msrlistBeans = msrListDao.findBymrListid(user_id);
        List<SongBean> songBeans = new ArrayList<SongBean>();
        for (MsrListBean m1 : msrlistBeans) {
            int a = m1.getMrslist_songid();
            SongBean songBean = songDao.findBySongid(a);
            songBeans.add(songBean);
        }
        return songBeans;
    }

    @Override
    public int insertSongBean(SongBean songBean) {
        return songDao.insertSongBean(songBean);
    }

    @Override
    public List<SongBean> findAll() {
        return songDao.findAll();
    }

    @Override
    public int updateByPrimaryKey(SongBean songBean) {
        return songDao.updateByPrimaryKey(songBean);
    }


    @Override
    public int deleteByPrimaryKey(int sid) {
        return songDao.deleteByPrimaryKey(sid);
    }


}
